package bramar.all;


import java.sql.Connection;
import java.sql.DriverManager;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 *
 * @author V V P L BRAMARNADH
 */
public class AccessToOracle {
public AccessToOracle() throws ClassNotFoundException, SQLException {
Class.forName("oracle.jdbc.driver.OracleDriver");
Class.forName("org.gjt.mm.mysql.Driver");
Connection ocon=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","scott","tiger");
Connection acon=DriverManager.getConnection("jdbc:mysql:///mydb1","root","root");
Statement st=acon.createStatement();
PreparedStatement ps=ocon.prepareStatement("insert into student values(?,?,?)");
ResultSet rs=st.executeQuery("select * from student");
while(rs.next())
{
    int no=rs.getInt(1);
    String name=rs.getString(2);
    String addrs=rs.getString(3);
    ps.setInt(1,no);
    ps.setString(2,name);
    ps.setString(3,addrs);
    ps.executeUpdate();
      
}        
 System.out.println("Records are moved successfully from Ms-Access to Oracle");
 rs.close();
 st.close();
 ps.close();
 acon.close();
 ocon.close();
 
    }

}
